/**
 * Copyright (c) 2010 Aldebaran Robotics All Rights Reserved
 */

#include <iostream>
#include <alcommon/alproxy.h>

using namespace std;

int main(int argc, char* argv[])
{
   if(argc != 2)
   {
      std::cerr << "Wrong number of arguments!" << std::endl;
      std::cerr << "Usage: helloworld NAO_IP" << std::endl;
      exit(2);
   }

   const std::string toSay = "Egidio LAVORA";
   try
   {
      // Create a proxy.
      // Arguments are:
      //  - name of the module
      //  - IP of the robot
      //  - port on which NaoQi is listening
      AL::ALProxy proxy ("ALMotion", argv[1], 9559);
	   AL::ALProxy proxySpeech("ALTextToSpeech", argv[1], 9559);

      // Call a method with no return value:
	   //string leg = "LLeg";
	   //proxy.callVoid("stepTo", leg, 0.04, 0.0, 0.0);
	   string param = "doubleVoice";
	   proxySpeech.callVoid("setParameter", param, 1);
	   param = "doubleVoiceLevel";
	   proxySpeech.callVoid("setParameter", param, 1.0);
	   param = "doubleVoiceTimeShift";
	   proxySpeech.callVoid("setParameter", param, 0.1);
	   param = "pitchShift";
	   proxySpeech.callVoid("setParameter", param, 1.1);
      proxySpeech.callVoid("say", toSay);

	   //leg = "RLeg";
	   //proxy.callVoid("stepTo", leg, 0.0, 0.0, 0.0);

	   //leg = "RLeg";
	   //proxy.callVoid("stepTo", leg, 0.04, 0.0, 0.0);

	   //leg = "LLeg";
	   //proxy.callVoid("stepTo", leg, 0.0, 0.0, 0.0);

	   //leg = "LLeg";
	   //proxy.callVoid("stepTo", leg, 0.04, 0.04, 0.0);

	   //leg = "RLeg";
	   //proxy.callVoid("stepTo", leg, 0.0, 0.04, 0.0);

	   //leg = "RLeg";
	   //proxy.callVoid("stepTo", leg, 0.04, -0.04, 0.0);

	   //leg = "LLeg";
	   //proxy.callVoid("stepTo", leg, 0.0, -0.04, 0.0);

	   proxy.callVoid("walkTo", 0.07, 0.07, 0.0);
	   proxy.callVoid("walkTo", 0.07, -0.07, 0.0);
   }
   catch (const AL::ALError& e)
   {
      std::cerr << "Caught exception: " << e.what() << std::endl;
      exit(1);
   }

   exit(0);
}
